#ifndef PASSWORDS_CLASS
#define PASSWORDS_CLASS
#include "password.h"
#include <vector>
#include <fstream>
#include <sstream>
namespace PASSWORDS
{
class passwordCollection
{
public:
	passwordCollection(void);
	passwordCollection(std::string file);
	bool loadCollection(std::string file);
	bool reloadCollection(void);
	bool saveCollection(void);
	bool saveColeectionAs(std::string file);
	//manually manipulate
	void addEntry(password entry);
	void addEntry(std::string name, std::string userPassword="NONE", std::string usage="NONE", std::string userHint="NONE");
	void removeEntry(password);
	void removeEntry(std::string name);
	//exact entries
	password getEntryByUserName(std::string name);
	password getEntryByHint(std::string hint);
	password getEntryByReference(std::string ref);
	//search by partial entries 
	std::vector<password> findEntryByUserName(std::string name);
	std::vector<password> findEntryByHint(std::string hint);
	std::vector<password> findEntryByReference(std::string ref);
	//password interface
	bool setMasterPassword(std::string password);
	std::string& getMasterPassword();
	~passwordCollection(void);
private:
	std::vector<password> passwordEntries;
	std::string collectionFile;	
	std::stringstream memoryStream;
	void xor(std::string &inString);
	void xor(char *inString, int stringSize);
	std::string masterPassword;
	std::fstream passwordFile;
	void encrypt(void);
	void decrypt(void);
};

}// end namespace PASSWORDS
#endif PASSWORDS_CLASS